//
//  USTarotCorrelationCell.m
//  us
//
//  Created by karry on 2025/6/24.
//

#import "USTarotCorrelationCell.h"

@implementation USTarotCorrelationCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    
    [self setNameAtt];
    
    
    self.imgView1.layer.cornerRadius = 6;
    self.imgView1.layer.masksToBounds = YES;
    self.imgView2.layer.cornerRadius = 6;
    self.imgView2.layer.masksToBounds = YES;
    
    CGFloat angle = -15.0 * M_PI / 180.0; // 转换成弧度
    self.imgView1.transform = CGAffineTransformMakeRotation(angle);
    self.imgView2.transform = CGAffineTransformMakeRotation(-angle);
    
    USDashedLineView *lineView = [[USDashedLineView alloc]initWithFrame:CGRectMake(0, 0, self.jk_width, 1.2)];
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(20);
        make.right.mas_offset(-20);
        make.bottom.mas_offset(0);
        make.height.mas_equalTo(1.2f);
    }];
    self.selectionStyle = UITableViewCellSelectionStyleNone;

    
}

-(void)setNameAtt {
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    style.lineSpacing = 6; // 设置行间距
    style.alignment = NSTextAlignmentLeft;

    // 设置主文字字体
    UIFont *nicknameFont = [UIFont fontWithName:@"AaJiandaoshitoubuNon-CommercialUse" size:16];
    UIFont *relNicknameFont = [UIFont fontWithName:@"AaJiandaoshitoubuNon-CommercialUse" size:16];
    UIFont *bottomFont = [UIFont systemFontOfSize:24 weight:UIFontWeightSemibold];

    // 统一段落样式
    NSDictionary *nicknameAttrs = @{
        NSParagraphStyleAttributeName: style,
        NSFontAttributeName: nicknameFont
    };

    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ ", USUser.user.nickname] attributes:nicknameAttrs];

    // 图片
    NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
    attachment.image = [UIImage imageNamed:@"ic_love"];
    attachment.bounds = CGRectMake(0, -2, 16, 16); // 调整图片大小和对齐
    NSAttributedString *iconString = [NSAttributedString attributedStringWithAttachment:attachment];
    [text appendAttributedString:iconString];

    // 另一昵称
    NSDictionary *relNicknameAttrs = @{
        NSParagraphStyleAttributeName: style,
        NSFontAttributeName: relNicknameFont
    };
    NSMutableAttributedString *text1 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", USUser.user.relUser.nickname] attributes:relNicknameAttrs];
    [text appendAttributedString:text1];

    // 底部文案
    NSDictionary *bottomAttrs = @{
        NSParagraphStyleAttributeName: style,
        NSFontAttributeName: bottomFont
    };
    NSAttributedString *together = [[NSAttributedString alloc] initWithString:@"\n我们的相性" attributes:bottomAttrs];
    [text appendAttributedString:together];

    self.nameLab.attributedText = text;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
